

package com.base.test.security.exception;



import com.base.commons.tools.exception.BaseOfExceptionHandler;
import com.base.commons.tools.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.security.access.AccessDeniedException;

/**
 * 异常处理器
 *
 * @author carl
 * @since 1.0.0
 */
@RestControllerAdvice
@Slf4j
@Order(Ordered.HIGHEST_PRECEDENCE)
public class SecurityExceptionHandler extends BaseOfExceptionHandler {
	@ExceptionHandler(AccessDeniedException.class)
	public Result handleAccessRE(AccessDeniedException ex){
		log.error(ex.getMessage(),ex);
		return Result.forbidden(ex.getMessage());
	}

}